<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TechHub 电脑学习社区</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        :root {
            --primary: #3B82F6;
            --secondary: #2563EB;
            --accent: #60A5FA;
            --background: #F8FAFC;
            --text: #1E293B;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', system-ui, sans-serif;
        }

        body {
            background: var(--background);
            color: var(--text);
            line-height: 1.6;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 2rem;
        }

        /* 导航样式 */
        .nav {
            display: flex;
            gap: 1rem;
            margin-bottom: 3rem;
            padding: 1rem;
            background: white;
            border-radius: 1.5rem;
            box-shadow: 0 4px 30px rgba(0,0,0,0.1);
        }

        .nav-button {
            padding: 1rem 2rem;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            border: none;
            border-radius: 1rem;
            cursor: pointer;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .nav-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
        }

        .nav-button.active {
            background: linear-gradient(135deg, var(--secondary), var(--accent));
        }

        /* 内容区域 */
        .content-section {
            display: none;
            opacity: 0;
            transform: translateY(20px);
            transition: all 0.4s ease;
        }

        .content-section.active {
            display: block;
            opacity: 1;
            transform: translateY(0);
        }

        /* 卡片设计 */
        .card {
            background: white;
            border-radius: 1.5rem;
            padding: 2rem;
            box-shadow: 0 4px 30px rgba(0,0,0,0.05);
            margin-bottom: 2rem;
        }

        /* 下载列表 */
        .download-list {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 1.5rem;
            margin-top: 2rem;
        }

        .download-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1.5rem;
            background: var(--background);
            border-radius: 1rem;
            border: 2px solid #E2E8F0;
            transition: all 0.3s ease;
        }

        .download-item:hover {
            transform: translateY(-3px);
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
        }

        /* 评论区域 */
        .comment-section {
            background: white;
            border-radius: 1.5rem;
            padding: 2rem;
            box-shadow: 0 4px 30px rgba(0,0,0,0.05);
        }

        .comment-list {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            margin-top: 2rem;
        }

        .comment-item {
            display: flex;
            gap: 1rem;
            padding: 1.5rem;
            background: var(--background);
            border-radius: 1rem;
            animation: slideIn 0.3s ease;
        }

        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: var(--primary);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            flex-shrink: 0;
        }

        .comment-content {
            flex: 1;
        }

        .comment-meta {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-bottom: 0.5rem;
        }

        .comment-author {
            font-weight: 600;
            color: var(--text);
        }

        .comment-time {
            color: #64748B;
            font-size: 0.9em;
        }

        #commentForm {
            margin-top: 2rem;
        }

        #commentInput {
            width: 100%;
            padding: 1.5rem;
            border: 2px solid #E2E8F0;
            border-radius: 1rem;
            resize: none;
            transition: all 0.3s ease;
        }

        #commentInput:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        @keyframes slideIn {
            from { opacity: 0; transform: translateX(20px); }
            to { opacity: 1; transform: translateX(0); }
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 导航 -->
        <nav class="nav">
            <button class="nav-button active" onclick="showSection('home')">
                <i class="fas fa-home"></i>首页
            </button>
            <button class="nav-button" onclick="showSection('pdf')">
                <i class="fas fa-file-pdf"></i>PDF教程
            </button>
            <button class="nav-button" onclick="showSection('software')">
                <i class="fas fa-download"></i>软件下载
            </button>
            <button class="nav-button" onclick="showSection('comments')">
                <i class="fas fa-comments"></i>社区交流
            </button>
        </nav>

        <!-- 首页 -->
        <section id="home" class="content-section active card">
            <h1>欢迎来到 TechHub</h1>
            <p>探索计算机的无限可能</p>
        </section>

        <!-- PDF下载 -->
        <section id="pdf" class="content-section card">
            <h2><i class="fas fa-book-open"></i>精选教程</h2>
            <div class="download-list">
                <div class="download-item">
                    <span>Python入门教程</span>
                    <a href="python.pdf" download class="nav-button">
                        <i class="fas fa-download"></i>
                    </a>
                </div>
                <div class="download-item">
                    <span>JavaScript高级编程</span>
                    <a href="javascript.pdf" download class="nav-button">
                        <i class="fas fa-download"></i>
                    </a>
                </div>
            </div>
        </section>

        <!-- 软件下载 -->
        <section id="software" class="content-section card">
            <h2><i class="fas fa-download"></i>开发工具</h2>
            <div class="download-list">
                <div class="download-item">
                    <span>Visual Studio Code</span>
                    <a href="vscode.exe" download class="nav-button">
                        <i class="fas fa-download"></i>
                    </a>
                </div>
                <div class="download-item">
                    <span>PyCharm Community</span>
                    <a href="pycharm.exe" download class="nav-button">
                        <i class="fas fa-download"></i>
                    </a>
                </div>
            </div>
        </section>

        <!-- 评论社区 -->
        <section id="comments" class="content-section">
            <div class="comment-section">
                <h2><i class="fas fa-comment-dots"></i>技术交流区</h2>
                <div class="comment-list" id="commentList">
                    <!-- 示例评论 -->
                    <div class="comment-item">
                        <div class="user-avatar">T</div>
                        <div class="comment-content">
                            <div class="comment-meta">
                                <span class="comment-author">TechMaster</span>
                                <span class="comment-time">2小时前</span>
                            </div>
                            <p>这个Python教程非常实用，推荐给大家！</p>
                        </div>
                    </div>
                </div>
                
                <form id="commentForm">
                    <textarea id="commentInput" placeholder="写下你的技术见解..."></textarea>
                    <button type="submit" class="nav-button" style="margin-top:1rem">
                        <i class="fas fa-paper-plane"></i>发布评论
                    </button>
                </form>
            </div>
        </section>
    </div>

    <script>
        // 页面切换逻辑
        function showSection(sectionId) {
            document.querySelectorAll('.content-section').forEach(section => {
                section.classList.remove('active');
            });
            document.querySelectorAll('.nav-button').forEach(btn => {
                btn.classList.remove('active');
            });
            
            setTimeout(() => {
                document.getElementById(sectionId).classList.add('active');
                event.target.classList.add('active');
            }, 50);
        }

        // 评论功能
        document.getElementById('commentForm').addEventListener('submit', e => {
            e.preventDefault();
            const commentText = document.getElementById('commentInput').value.trim();
            
            if (commentText) {
                const commentItem = document.createElement('div');
                commentItem.className = 'comment-item';
                commentItem.innerHTML = `
                    <div class="user-avatar">${getRandomAvatar()}</div>
                    <div class="comment-content">
                        <div class="comment-meta">
                            <span class="comment-author">${getRandomUsername()}</span>
                            <span class="comment-time">刚刚</span>
                        </div>
                        <p>${commentText}</p>
                    </div>
                `;
                
                document.getElementById('commentList').prepend(commentItem);
                document.getElementById('commentInput').value = '';
                saveComment(commentText);
            }
        });

        // 随机用户生成
        function getRandomAvatar() {
            const letters = 'ABCDEFGHIJKL';
            return letters[Math.floor(Math.random() * letters.length)];
        }

        function getRandomUsername() {
            const names = ['CodeMaster', 'DevPro', 'TechGuru', 'Pythonista', 'JavaExpert'];
            return names[Math.floor(Math.random() * names.length)];
        }

        // 本地存储评论
        function saveComment(comment) {
            let comments = JSON.parse(localStorage.getItem('comments') || '[]');
            comments.push({
                text: comment,
                author: getRandomUsername(),
                avatar: getRandomAvatar(),
                time: new Date().toLocaleString()
            });
            localStorage.setItem('comments', JSON.stringify(comments));
        }

        // 加载存储的评论
        function loadComments() {
            const comments = JSON.parse(localStorage.getItem('comments') || '[]');
            const commentList = document.getElementById('commentList');
            
            comments.forEach(comment => {
                const commentItem = document.createElement('div');
                commentItem.className = 'comment-item';
                commentItem.innerHTML = `
                    <div class="user-avatar">${comment.avatar}</div>
                    <div class="comment-content">
                        <div class="comment-meta">
                            <span class="comment-author">${comment.author}</span>
                            <span class="comment-time">${comment.time}</span>
                        </div>
                        <p>${comment.text}</p>
                    </div>
                `;
                commentList.appendChild(commentItem);
            });
        }

        // 初始化加载评论
        window.addEventListener('load', loadComments);
    </script>
</body>
</html>